/*
 * @Copyright: (C) 2019 Zhang Rida. All rights reserved.
 *
 * @Author: Zhang Rida
 * @Email: 215154317@qq.com
 * @FilePath: \WEILA_8910_PROJECT\Third-party\weilasdk\src\wlosal\src\wl_transport.h
 * @Date: 2021-02-18 15:07:07
 * @Description: socket transport for weila osal
 *
 * @LastEditors: Zhang Rida
 * @LastEditTime: 2021-05-13 17:00:44
 */

#ifndef _WL_TRANSPORT_H
#define _WL_TRANSPORT_H

#include "wl_inner.h"
#include "wl_types.h"
#include "wl_socket.h"

#ifdef __cplusplus
extern "C" {
#endif

typedef wl_int32 WL_SOCKET_DESCRIPTOR;

typedef enum {
    WL_TRANSPORT_EVENT_NONE      = 0x00,
    WL_TRANSPORT_EVENT_READ      = 0x01,
    WL_TRANSPORT_EVENT_WRITE     = 0x02,
    WL_TRANSPORT_EVENT_EXCEPTION = 0x04,
    WL_TRANSPORT_EVENT_ACCEPT    = 0x08,
    WL_TRANSPORT_EVENT_CONNECT   = 0x10,
    WL_TRANSPORT_EVENT_LOST      = 0x20,
    WL_TRANSPORT_EVENT_CLOSE     = 0x40
} WL_TRANSPORT_EVENT;

wl_int32             wl_transport_init(void);
void                 wl_transport_end(void);
wl_int32             wl_transport_process_message(wl_task_message* message);
WL_SOCKET            wl_transport_add_socket(WL_SOCKET_DESCRIPTOR sd, wl_int32 type, wl_int32 taskid);
wl_int32             wl_transport_delete_socket(WL_SOCKET socket);
wl_bool              wl_transport_set_socket_event(WL_SOCKET socket, wl_int32 event);
WL_SOCKET_DESCRIPTOR wl_transport_get_socket_descriptor(WL_SOCKET socket);
wl_int32             wl_transport_set_socket_callback(WL_SOCKET socket, wl_sock_callback callback, void* context);
wl_int32             wl_transport_get_socket_taskid(WL_SOCKET socket);

#ifdef __cplusplus
}
#endif /* __cplusplus */

#endif /*_WL_TRANSPORT_H*/
